<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			/**
			 * @param {TreeNode} root
			 * @return {number}
			 */
			function TreeNode(val, left, right) {
				this.val = (val === undefined ? 0 : val)
				this.left = (left === undefined ? null : left)
				this.right = (right === undefined ? null : right)
			}
			let r = new TreeNode(1,
				new TreeNode(2,
					new TreeNode(4, null, null),
					new TreeNode(5, null, null)),
				new TreeNode(3,
					new TreeNode(6, null, null),
					new TreeNode(7, null, null)));
			var maxDepth = function(root) {
				const deepTree = (root) => {
					if (root) {
						let l = deepTree(root.left);
						let r = deepTree(root.right);
						return Math.max(l,r) + 1;
					} else {
						return 0;
					}
				}
				return deepTree(root)
			};
			console.log(maxDepth(r));
		</script>
	</body>
</html>
